<?php

defined('_JEXEC') or die('Restricted access');

class ConsoleViewSetting extends JViewLegacy {
    
    protected $form = null;
    
    public function display($tpl = null) {
        $this->form = $this->get('Form');
        $this->item = $this->get('Item');
        
        if (count($errors = $this->get('Errors'))) {
            JError::raiseError(500, implode('<br />', $errors));
            
            return false;
        }
        
        $input = JFactory::getApplication()->input;
        $input->set('hidemainmenu', true);
        $isNew = ($this->item->id == 0);
        
        if ($isNew) {
            $title = 'Add configuration item';
        }
        else {
            $title = 'Edit configuration item';
        }
        
        JToolbarHelper::title($title, 'setting');
        JToolbarHelper::save('setting.save');
        JToolbarHelper::cancel(
            'setting.cancel',
            $isNew ? 'JTOOLBAR_CANCEL' : 'JTOOLBAR_CLOSE'
        );
        
        parent::display($tpl);
    }
}

